<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const pig = {
      uname: '佩奇',
      family: {
        mother: '猪妈妈',
        father: '猪爸爸',
        sister: '乔治'
      },
      age: 6
    }
    // 多级对象解构
    const { uname, family: { mother, father, sister }, age } = pig
    console.log(uname)  //佩奇
    console.log(mother)  //猪妈妈
    console.log(father)  //猪爸爸
    console.log(sister)  //乔治
    console.log(age)  //6


    // const person = [
    //   {
    //     uname: '佩奇',
    //     family: {
    //       mother: '猪妈妈',
    //       father: '猪爸爸',
    //       sister: '乔治'
    //     },
    //     age: 6
    //   }
    // ]
    // const [{ uname, family: { mother, father, sister }, age }] = person
    // console.log(uname)  //佩奇
    // console.log(mother)  //猪妈妈
    // console.log(father)  //猪爸爸
    // console.log(sister)  //乔治
    // console.log(age)  //6

  </script>
</body>

</html>